<%--
  Created by IntelliJ IDEA.
  User: zzf
  Date: 2021/1/7
  Time: 16:44
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ include file="/public/header/permissionCommon.jspf" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="itheima" uri="http://ChanghuXian.com/common/"%>


<html>
<head>
    <title>异常预警</title>
    <link href="${webPath}/css/Sign/bootstrap.min.css" rel="stylesheet">
</head>
<body class="layui-layout-body" onload="load()">
<div class="layui-layout layui-layout-admin">
    <!-- 头部和左侧导航-->
    <div id="header"></div>

    <!--右侧主体区域-->
    <div class="layui-body">
        <div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief">
            <ul class="layui-tab-title">
                <li id="roleListLi" class="layui-this">异常预警</li>
            </ul>

            <form class="layui-form" style="margin-top: 20px" action="${webPath}/SignRecord/getAbnormalbyName" id="picSearch" method="post">
                <div class="layui-form-item" style="margin-bottom: 0px">
                    <div class="layui-inline">
                        <label class="layui-form-label">护工名称</label>
                        <div class="layui-input-inline">
                            <input type="text" class="layui-input" name="vHG" placeholder="请输入护工名称">
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">老人名称</label>
                        <div class="layui-input-inline">
                            <input type="text" class="layui-input" name="vLR" placeholder="请输入老人名称">
                        </div>
                        <button type="submit" class="layui-btn" id="a">查询</button>
                    </div>
                </div>
            </form>

            <div class="layui-tab-content" style="height: 100px;">
                <div id="roleListDiv" class="layui-tab-item layui-show">
                    <table class="layui-table">
                        <thead>
                        <tr>
                            <th><input type="checkbox" id="all" value=""></th>
                            <th>清单编号</th>
                            <th>护工名称</th>
                            <th>老人名称</th>
                            <th>签到时间</th>
                            <th>中签时间</th>
                            <th>签退时间</th>
                            <th width="88px;">操作</th>
                        </tr>
                        </thead>
                        <tbody id="tbody">
                        <c:forEach items="${page.rows}" var="u">
                            <tr>
                                <td><label><input type="checkbox" value="${u.id}" name="id"></label></td>
                                <td>${u.id}</td>
                                <td>${u.hg_id}</td>
                                <td>${u.lr_id}</td>
                                <td><fmt:formatDate value="${u.f_sign}" pattern="yyyy-MM-dd HH:mm:ss"/></td>
                                <td><fmt:formatDate value="${u.s_sign}" pattern="yyyy-MM-dd HH:mm:ss"/></td>
                                <td><fmt:formatDate value="${u.t_sign}" pattern="yyyy-MM-dd HH:mm:ss"/></td>
                                <td>
                                    <button class="layui-btn " onclick="delSignRecord(${u.id})">删除</button>
                                </td>
                            </tr>
                        </c:forEach>
                        </tbody>
                    </table>
                </div>

                <!-- 分页条信息 -->
                <div class="col-lg-6" style="margin-top: -15px;margin-left: -15px">
                    <itheima:page url="${webPath}/SignRecord/getSignRecordbyName" />
                </div>
            </div>


        </div>
    </div>

    <!--底部-->
    <div id="footer"></div>
    <script>
        $("#header").load("${webPath}/publicPages/permission/fragments/header.jsp");
        $("#footer").load("${webPath}/publicPages/permission/fragments/footer.jsp");
    </script>
    <script type="text/javascript" src="${webPath}/js/permission/dateUtils.js"></script>

</div>
</body>
<script>
    function delSignRecord(id) {
        if (null != id) {
            layer.confirm('您确定要删除这条吗？', {
                btn: ['确认', '返回'] //按钮
            }, function () {
                $.post("/SignRecord/delSignRecord", {"id": id}, function (data) {
                    if (data == "OK") {
                        //回调弹框
                        layer.alert("删除成功！", function () {
                            layer.closeAll();
                            //加载load方法
                            window.name = "0";
                            load();//自定义
                        });
                    } else {
                        layer.alert(data);//弹出错误提示
                    }
                });
            }, function () {
                layer.closeAll();
            });
        }
    }

    function load()
    {
        if(window.name == null || window.name == "" || window.name == "0"){
            document.getElementById("a").click();
            window.name = "1";
        }
    }
</script>
</html>
